<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>sessionStorage</title>
	</head>
	<body>
		<button onclick="test1()">点我向sessionStorage中存入数据</button> <br><br>
		<button onclick="test2()">点我向sessionStorage中读取数据</button> <br><br>
		<button onclick="test3()">点我删除sessionStorage中的数据</button> <br><br>
		<button onclick="test4()">点我清空sessionStorage</button> <br><br>

		<script type="text/javascript" >
			let person = {
				name:'张三',
				age:18
			}

			function test1(){
				sessionStorage.setItem('ren',JSON.stringify(person))
			}

			function test2(){
				let x = sessionStorage.getItem('ren')
				console.log(JSON.parse(x))
			}

			function test3(){
				sessionStorage.removeItem('ren')
			}

			function test4(){
				sessionStorage.clear()
			}
		</script>
	</body>
</html>